<template>
  <Modal v-model="modal" :width="800" title="评论">
      <Form :label-width="160" ref="form" :rules="rule" :model="form">
        <FormItem label="评论" prop="imgPath">
          <Input
            class="start"
            v-model.trim="form.content"
            placeholder="评论"
            type="textarea"
            @on-enter="onSearchBtnClick">
          </Input>
        </FormItem>
      </Form>
    <div slot="footer">
      <Button class="mr" size="large" type="text" @click="closeModal">取消</Button>
      <Button type="primary" size="large" :disabled="disabled" @click="onSave">确定</Button>
    </div>
  </Modal>
</template>
<script>
import PictureEditItem from "@/components/PictureEditItem"
export default {
  components: {
    PictureEditItem
  },
  data() {
    return {
      modal: false,
      disabled: false,
      storeContractId: null,
      form: {
         content: []
      },
      order_id: '',
      uploadList: []
    }
  },
  methods: {
    getData() {
      this.$ajaxGet(`/order/getDiscuss`, {order_id: this.order_id}).then(data => {
         this.form.content = data.content
      })
    },
    updataForm(id) {
      this.$refs.form.resetFields()
      this.form = {
        rewardIntegral: '',
        rewardRemark: ''
      }
      
      this.disabled =  false
      this.company_id = id
      this.openModal()
    },
    openModal(item) {
      this.modal = true;
      this.order_id = item.order_id
      this.getData(item)
    },
    uploadPic(value) {
      this.form.imgPath = value.length > 0 ? value.map(item => item.url) : value[0].url;
    },
    closeModal() {
      this.modal = false
    },
    onSave() {
        let param = {
          order_id: this.order_id,
          content: this.form.content
        }
          this.$jsonPost(`/order/addDiscuss`, param).then(data => {
            this.closeModal()
            this.$Notice.success({
              title: '操作成功'
            })
            this.this.form.content = ''
            this.$emit("complete")
          }).catch(() => {
            this.closeModal()
          })
    }
  }
}
</script>
